<template>
  <view>
    <uni-nav-bar shadow :statusBar="true" :border="false" :fixed="true" title="我的" />
    <uni-list>
      <uni-list-item :title="userInfo.username" :note="userInfo.loginname" :thumb="userInfo.avatar"
                     thumb-size="lg" rightText="修改" link to="/pages/vue/index/index"></uni-list-item>
      <uni-list-item title="检查更新" link to="/pages/vue/index/index"></uni-list-item>
      <uni-list-item title="退出登录" class="logout" clickable @click="logoutClick()"></uni-list-item>
    </uni-list>
    <uni-popup ref="inputDialog" type="dialog">
      <uni-popup-dialog type="info" cancelText="取消" confirmText="确定" title="是否退出登录" content="" @confirm="dialogConfirm"
      ></uni-popup-dialog>
    </uni-popup>
  </view>
</template>

<script>
import userApi from "@/api/sys/user";
import websocket from "@/utils/websocket";
export default {
  data() {
    return {
      userInfo: {
        username: '用户名',
        loginname: '登录名',
        avatar: '',
      },

    };
  },
  mounted() {
    this.getUserInfo()
  },
  methods: {
    async getUserInfo() {
      await userApi.getUserInfo().then(res => {
        this.userInfo = res.data
      })
    },
    dialogConfirm(e){
      userApi.logout().then(res => {
        uni.reLaunch({
          url: 'login'
        })
        websocket.closeWebSocket();
      })
    },
    logoutClick(){
      this.$refs.inputDialog.open()
    }
  },
}
</script>

<style lang="scss">
/deep/ .uni-list-item__content-title{
  font-size: 28rpx;
  font-weight: bold !important;
  color: #35363a !important;
}
.logout{
  text-align: center;
}
</style>
